package com.company.cloud.company.modules.app.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.company.cloud.common.asserts.ValidatorUtils;
import com.company.cloud.common.auth.annotation.Login;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.common.utils.AuthContextUtils;
import com.company.cloud.company.modules.api.request.CompanyQueryRequest;
import com.company.cloud.company.modules.api.response.CompanyFull;
import com.company.cloud.company.modules.app.controller.req.CompanyQuery4PageParam;
import com.company.cloud.company.modules.base.entity.BaseProfitConfig;
import com.company.cloud.company.modules.base.service.BaseProfitConfigService;
import com.company.cloud.company.modules.cache.utils.CompanyConvertUtils;
import com.company.cloud.company.modules.mgr.controller.req.BaseProfitSaveParam;
import com.company.cloud.company.modules.mgr.service.BaseProfitMgrService;
import com.company.cloud.company.modules.mgr.service.CompanyMgrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Log4j2
@Login
@RestController
@RequestMapping("/app/user/baseProfit")
@Api(tags="BaseProfit_Mgr_公司分佣基础配置")
public class BaseProfitMgrController {

    @Autowired
    private BaseProfitMgrService baseProfitMgrService;

    @PostMapping("/saveOrEdit")
    @ApiOperation(value="新增/修改", response= BaseResult.class)
    public BaseResult save(@RequestBody BaseProfitSaveParam params) {
        ValidatorUtils.validate(params);
        LoginSimpleUserInfo userInfo = AuthContextUtils.getUser();
        baseProfitMgrService.saveOrEdit(params, userInfo.getCompanyNo(), userInfo);
        return BaseResult.ok();
    }

    @GetMapping("/get")
    @ApiOperation(value="查询", response= BaseResult.class)
    public BaseResult get() {
        LoginSimpleUserInfo userInfo = AuthContextUtils.getUser();
        return BaseResult.ok(baseProfitMgrService.get(userInfo.getCompanyNo()));
    }





}
